package com.ac.input.config;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.ac.input.dm.HndInpDefItm;
import com.ac.input.util.CompareViews;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright AgileCentury 2004</p>
 * <p>Company: AgileCentury</p>
 * @author <a href="mailto:lianzs@tom.com">Lianzs</a>
 * @version 1.0
 */

public class ViewClass implements Serializable {
	private static final long serialVersionUID = 1L;
    private List dmUnList = new ArrayList();
    private List dmInList = new ArrayList();
    private List dmKeyList = new ArrayList();
    private List dmList = new ArrayList();
    private String viewStr;
    private String orgIdName;

    public ViewClass() {}

    public ViewClass(List list) {
        for (int i = 0; i < list.size(); i++) {
            HndInpDefItm dm = (HndInpDefItm) list.get(i);
            if (dm.isOrgId()) {
                orgIdName = dm.getColCode();
            }
            if (dm.isKey()) {
                dmKeyList.add(dm);
            }
            if (dm.isVisible()) {
                if (dm.isInput()) {
                    dmInList.add(dm);
                }
                dmList.add(dm);
            } else {
                dmUnList.add(dm);
            }
        }
        java.util.Collections.sort(dmList, new CompareViews());

        if (dmList.size() == 0) {
            viewStr = "*";
        } else {
            viewStr = "";
            for (int i = 0; i < dmList.size(); i++) {
                HndInpDefItm dm = (HndInpDefItm) dmList.get(i);
                //if("3".equals(dm.getColType())){
                //	viewStr += "to_char("+dm.getColId() + ",'yyyy-mm-dd'),";
                //}else{
                viewStr += dm.getColCode() + ",";
                //}
            }
            viewStr = viewStr.substring(0, viewStr.length() - 1);
        }
    }

    public List getChildren() {
        return dmList;
    }

    public List getDmUnList() {
        return dmUnList;
    }

    public List getDmInList() {
        return dmInList;
    }

    public List getDmKeyList() {
        return dmKeyList;
    }

    public String getViewStr() {
        return viewStr;
    }

    public String getOrgIdName() {
        return orgIdName;
    }
}
